package com.springboot.others.mapper;

import com.springboot.others.entity.Address;
import org.apache.ibatis.annotations.*;

@Mapper
public interface AddressMapper {

    @Select("select address_id,address, address2, district, city_id, postal_code, phone," +
            "ST_AsText(location) location, last_update from address where address_id = #{addressId}")
    Address getAddressById(Integer addressId);

    @Insert("insert into address values (null,#{address},#{address2},#{district},#{cityId},#{postalCode}," +
            "#{phone},ST_GeomFromText(#{location}),now())")
    @Options(useGeneratedKeys = true,keyProperty = "addressId")
    void insert(Address address);

    void update(Address address);
}
